var key_signature = "signature";
var signature = "서명입니다!";
var widgetBtn = 0;
var authInfo  = null;

var key_theme 		= "theme";	
var selectTheme 	= "white";


function init() {
	
	checkTheme();
	authInfo  = alopexController.parameters["authInfo"];
	
    //if(preference.getString(key_signature, "") == "")
	//	preference.putString(key_signature, signature);
	
	signature = preference.getString(key_signature);
	document.getElementById('textarea').value = signature;

	//-------------Black & White 테마 및 Widget 보여주기 함수
	widgetBtn.setOnClickHandler(widgetBtn_click);
	widgetClose.setOnClickHandler(widgetBtn_click);	
	thememSelPanel.setOnClickHandler(changeTheme);
	thememSelPanelIn.setOnClickHandler(changeTheme);
	slideImg.setOnClickHandler(changeTheme);
	
	mailImg.setOnClickHandler(btnClickAtSign);
	boardImg.setOnClickHandler(btnClickAtSign);
	contactImg.setOnClickHandler(btnClickAtSign);
	scheduleImg.setOnClickHandler(btnClickAtSign);
	wtImg.setOnClickHandler(btnClickAtSign);
	
	
	
	optToolBarItems1.setOnClickHandler(confirm);
	optBtns1.setOnClickHandler(confirm);
	optLabels1.setOnClickHandler(confirm);
	optToolBarItems2.setOnClickHandler(confirm);
	optBtns2.setOnClickHandler(confirm);
	optLabels2.setOnClickHandler(confirm);
	
	alopexController.setCustomizedBack(btnBackClick);
}
function btnClickAtSign(e){
	
	switch ( e.target.id ){
	
	case "mailImg":
		alert("메일앱");
		break;
		
	case "boardImg":
		alert("게시판앱");
		break;
	
	case "contactImg":
		alert("주소록앱");
		break;
		
	case "scheduleImg":
		alert("스케줄러앱");
		break;
		
	case "wtImg":
		alert("winstops");
		break;
		
	case "hiskImg":
		alert("hisk");
		break;
	}
}

function confirm(){
	
	if(document.getElementById('textarea').value==""){
		preference.putString(key_signature, " ");
	}else{
		preference.putString(key_signature, document.getElementById('textarea').value);
	}
		
	alopexController.goStartPage();

}

function btnBackClick(){
	
	alopexController.goStartPage();
	
}

function widgetBtn_click(){
	
	if ( widgetBtn == 0 ){
		widgetBtn = 1;
		document.getElementById("widgetPanel").style.display = "block";
		
		
	} else {
		widgetBtn = 0;
	
		document.getElementById("widgetPanel").style.display = "none";
		
	}
}

function checkTheme(){
	
	var selectTheme = preference.getString(key_theme);
	
	if ( selectTheme == "black" ){
		document.getElementById("themePanel").className = "themePanel_b";
		
	} else if ( selectTheme == "white" ){
		document.getElementById("themePanel").className = "themePanel_w";
		
	} 
	
}

function changeTheme(){
	
	if ( selectTheme == "black" ){ 
		document.getElementById("slideImg").className = "Image";
		selectTheme = "white"; 
		
	} else if ( selectTheme == "white" ){ 
		document.getElementById("slideImg").className = "ImageW";
		selectTheme = "black"; 
		
	}
	preference.putString( key_theme, selectTheme );
	checkTheme();
	
}

